Page({
  data:{
    lblist:[],
    isLogin:false,
    productList:[],
    activityList:[],
    userInfo:""
  },
  //加载页面时会先执行这个生命周期
  onLoad(){
    this.getlblist(),
    this.getProductList(),
    this.getActivityList()
    
  },
  // 页面每次显示都会显示这个
  onShow(){
    let userInfo = wx.getStorageSync('userInfo')
    if(userInfo!=null && userInfo!=""){
      this.setData({
        isLogin:true,
        userInfo:userInfo
      })
    }else{
      isLogin:false,
        userInfo=""
    }
  },
    getlblist(){
    wx.request({
      url: 'http://localhost:9527/imgs/0',
      method:'GET',
      success:res=>{
        // console.log(res),
        this.setData({
          lblist:res.data.data
        })
      }
    })
  },
  getProductList(){
    wx.request({
      url: 'http://localhost:9527/products/recommend/1',
      method:'GET',
      success:res=>{
        // console.log(res)
        this.setData({
          productList:res.data.data
        })
      }
    })
  },
  getActivityList(){
    wx.request({
      url: 'http://localhost:9527/activites/',
      method:'GET',
      success:res=>{
        // console.log(res)
        this.setData({
          activityList:res.data.data
        })
      }
    })
  },
  toLogin(){
    console.log(1)
    wx.navigateTo({
      url: '/pages/login/login',
    })
   
  }

})